/*
 *  WRenderer.h
 *  GLRender
 *
 *  Created by Patrick zulian on 5/5/10.
 *  Copyright 2010 University  of Lugano. All rights reserved.
 *
 */

#ifndef W_RENDERER_H
#define W_RENDERER_H

#include "Base.h"
#include "Utils.h"

#include "AbstractRenderer.h"
#include "Asteroid.h"
#include "WTarget.h"
#include "Texture.h"
#include "CollisionSystem.h"
#include "Projectile.h"
#include "WCockpitRenderer.h"
#include "Light.h"
#include "Bonus.h"


class WRenderer : public AbstractRenderer {
private:
	Light * spaceShipLight;
	void drawLineCube();
	
	std::vector<Texture *> asteroidTextures, planetTextures;
	std::vector<GLuint> asteroidMeshes;
	Texture skyboxTexture;
	
	WCockpitRenderer cockpitRenderer;

protected:
	virtual
	GLuint initCross();
	GLuint initCube();
	GLuint initTorus();
		
	GLuint CROSS_DL, SHUTTLE_DL, SKYBOX_DL, CUBE_DL, TORUS_DL, GLU_SPHERE_DL;
	
public:
	GLuint SPHERE_DL, FRAGMENT_DL;
	WMaterial defaultAsteroidMat, defaultObjectiveMat;
	WRenderer();
	
	virtual
	~WRenderer();
	
	void
	initialize();
	
	void drawSphere();
	
	void drawTorus();
	
	
	GLuint initMesh(const char * name);
	void render(const GLObject * glObject);
	void defaultTransform(const WObject * object);
	
	
	virtual
	void renderAsteroid(const Asteroid* asteroid);
	
	virtual
	void renderObjective(const WTarget *objective);
	
	virtual
	void renderCockpit(Player *player);
	
	virtual
	void renderSkyBox();
	
	virtual
	void renderCross();
	
	virtual
	void renderWNode(const WNode * node);
	
	virtual
	void renderProjectile (const Projectile *p);

	virtual
	void renderBonus (const Bonus *b);

	virtual
	void renderFlash(const RGBd &rgb, const int duration = 20);
	
	virtual 
	void renderFragment();
	
	virtual
	void setUpAsteroid(GLObject * object);
	
	virtual
	void setUpPlanet(GLObject * object);
	
	GLuint initGLUSphere(const int n);
};

#endif
